﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MDA;


/// <summary>
/// 用户登录页面
/// </summary>
public partial class login : CommanPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //清空缓存方法
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.Cache.SetAllowResponseInBrowserHistory(false);
        this.NeedAuth = false;
        tbUserName.Focus();
    }
    /// <summary>
    /// 登录按钮实现。

    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button1_Click(object sender, EventArgs e)
    {
        UsersRule ur = new UsersRule();
        string pw = FormsAuthentication.HashPasswordForStoringInConfigFile(tbPassword.Text.Trim(), "MD5");
        if (ur.ValidUserLoad(tbUserName.Text, pw))
        {
            LogRule lr = new LogRule();
            lr.LoginLog(tbUserName.Text,Request.UserHostAddress);
            T_USERAccess ac = new T_USERAccess();
            //ac.Excute("delete from t_report where username='"+tbUserName.Text.Trim()+"'");
            FormsAuthentication.RedirectFromLoginPage(tbUserName.Text, false);
            //Response.Redirect(FormsAuthentication.GetRedirectUrl(tbUserName.Text,false));

            //FormsAuthentication.SetAuthCookie(tbUserName.Text, false);
            //Response.Redirect(FormsAuthentication.GetRedirectUrl(tbUserName.Text,false));

        }
    }
}
